package com.twu.biblioteca.ui;

import com.twu.biblioteca.data.User;
import com.twu.biblioteca.data.UserDAO;

/**
 * Created by florian on 5/01/14.
 */
public class LoginController implements ScreenController{
    private final BibliotecaUI ui;
    private final UserDAO dao;
    private final ScreenControllerFactory controllerFactory;

    public LoginController(BibliotecaUI ui, UserDAO dao, ScreenControllerFactory controllerFactory) {
        this.ui = ui;
        this.dao = dao;
        this.controllerFactory = controllerFactory;
        ui.showLoginMessage();
    }

    @Override
    public ScreenController processCommand(String line) {
        User user = dao.getUserByLibraryNumber(line);
        return controllerFactory.createLoginPasswordController(user);
    }
}
